import request from '@/config/axios'

// 店员等级 VO
export interface ClerkLevelVO {
  id: number // 编号
  level: number // 等级
  name: string // 名称
  img: string // 图片
  money: number // 业绩要求
  goodsList: string // 商品列表
  weight: number // 排序
}

// 店员等级价格 VO
export interface ClerkLevelPriceVO {
  id: number // 编号
  categoryList: ClerkLevelVO // 价格
}

// 店员等级 API
export const ClerkLevelApi = {
  // 查询店员等级分页
  getClerkLevelPage: async (params: any) => {
    return await request.get({ url: `/worker/clerk-level/page`, params })
  },

  // 查询店员等级详情
  getClerkLevel: async (id: number) => {
    return await request.get({ url: `/worker/clerk-level/get?id=` + id })
  },
  
  // 查询店员等级列表
  getClerkLevelList: async () => {
    return await request.get({ url: `/worker/clerk-level/getClerkLevelList` })
  },
  
  // 查询店员等级价格
  getClerkLevelPrice: async (id: number) => {
    return await request.get({ url: `/worker/clerk-level/list?id=` + id })
  },

  // 新增店员等级
  createClerkLevel: async (data: ClerkLevelVO) => {
    return await request.post({ url: `/worker/clerk-level/create`, data })
  },

  // 修改店员等级
  updateClerkLevel: async (data: ClerkLevelVO) => {
    return await request.put({ url: `/worker/clerk-level/update`, data })
  },
  
  // 修改状态
  updateClerkLevelStatus: async (id: number, status: boolean) => {
    const data = {
      id,
      status
    }
    return await request.put({ url: '/worker/clerk-level/update-status', data: data })
  },
  
  // 修改店员等级价格
  updateClerkLevelPrice: async (data: ClerkLevelPriceVO) => {
    return await request.put({ url: `/worker/clerk-level/save`, data })
  },

  // 删除店员等级
  deleteClerkLevel: async (id: number) => {
    return await request.delete({ url: `/worker/clerk-level/delete?id=` + id })
  },

  // 导出店员等级 Excel
  exportClerkLevel: async (params) => {
    return await request.download({ url: `/worker/clerk-level/export-excel`, params })
  },
}